package com.gameShare.utils

import kotlin.random.Random

class RandomUtils {

    companion object{
        /**
         * 生成一个随机的bool量，概率为五五开
         *
         * @return
         */
        fun randomBool() : Boolean{
            return Random.nextInt(1,100) % 2 == 0
        }

        /**
         * 生成一个随机字母
         *
         * @return
         */
        fun randomChar() : Char{
            val totalLetters = 26 + 26
            val randomIndex = Random.nextInt(0, totalLetters)
            val isUppercase = randomIndex < 26
            val baseChar = if (isUppercase) 'A' else 'a'
            val offset = if (isUppercase) randomIndex else randomIndex - 26
            return (baseChar.code + offset).toChar()
        }

        /**
         * 生成一个随机数字
         *
         * @return
         */
        fun randomNumber() : String{
            return Random.nextInt(0, 9).toString()
        }
    }

}